package com.deram.ctin.rest.web.controller.web;

import com.deram.ctin.rest.web.result.web.WebEnterDownloadGeneratePdfResult;
import com.deram.ctin.serv.enter.entity.EnterInfo;
import com.deram.ctin.serv.main.api.EnterDetailApi;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author zhangcm
 * @version 1.0, 2017/9/25
 */
@Api(tags = {"web - 企业下载接口"})
@RestController
@RequestMapping("/web/enterDownload")
public class WebEnterDownloadController {

    @Autowired
    private EnterDetailApi enterDetailApi;

    @ApiOperation(value = "生成PDF")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "ID", required = true, paramType = "path")
    })
    @PostMapping("/generatePdf/{id}")
    public WebEnterDownloadGeneratePdfResult generatePdf(@PathVariable Long id){
        WebEnterDownloadGeneratePdfResult result = new WebEnterDownloadGeneratePdfResult();
        EnterInfo enterInfo = enterDetailApi.execGeneratePdf(id);
        result.setUrl(enterInfo.getPdfUrl());
        return result;
    }
}
